<?php

class users{	
	function id(){
		return (int)$_SESSION['user_id'] ;
	}
	function userName(){
		return $_SESSION['userName'] ;
	}
	function powder(){
		return (int)$_SESSION['userPowder'] ;
	}
	function getUser($user_id=0){
		global $dbs , $user;
		if( $user_id == 0) 
			$user_id = self::id() ;
		$sql = 'SELECT * FROM `'. DB_PRE .'user` WHERE `id` = '. (int)$user_id ;
		$userInfo = $dbs -> select($sql);
		if( count($userInfo) == 0 )
			return self::creatNullUser();
		else
			return $userInfo[0];;
	}
	function creatNullUser(){
		$return = array(
			'id' => -1,
			'userName' => '此用户已被删除',
			'nickName' => '此用户已被删除',
			'user_id' => -1	,		
		);	
		return $return;	
	}


}
?>